﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JXT.PrimaryKey.Batman.Web.Mvc.Models
{
    public class ViewMessage
    {
        public string Title { get; set; }

        public string Message { get; set; }

        public MessageIcon Icon { get; set; }

        public List<JumpUrl> Urls { get; set; }

        public ViewMessage()
        {
            Icon = MessageIcon.Information;
            Title = "SystemWeb_CommonString_SystemError";
            Urls = new List<JumpUrl>();
            Urls.Add(new JumpUrl());
        }
    }

    public enum MessageIcon
    {
        Information = 1,
        Question,
        Warning,
        Error
    }

    public class JumpUrl
    {
        public string Text { get; set; }

        public bool IsBlank { get; set; }

        public JumpType Type { get; set; }

        public object Value { get; set; }

        public JumpUrl()
        {
            IsBlank = false;
            Type = JumpType.Url;
            Text = "SystemWeb_CommonString_Back";
            Value = "javascript:history.back();";
        }

        public static JumpUrl Create(string text, object value, bool isBlank = false)
        {
            JumpUrl url = new JumpUrl()
            {
                Text = text,
                IsBlank = isBlank,
                Value = value
            };
            if (value is String)
            {
                url.Type = JumpType.Url;
            }
            else
            {
                url.Type = JumpType.Route;
            }
            return url;
        }
    }

    public enum JumpType
    {
        Route = 1,
        Url
    }
}
